﻿using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Threading.Tasks;

namespace DaveSexton.Labs
{
	[ContractClass(typeof(IGUIConsoleLabContract))]
	internal interface IGUIConsoleLab : ILab
	{
		Task<bool> ExperimentStartingAsync(IList<IExperiment> experiments, int index);

		Task ExperimentExecutingAsync(IList<IExperiment> experiments, int index);

		Task ExperimentCompletedAsync(IList<IExperiment> experiments, int index);
	}

	[ContractClassFor(typeof(IGUIConsoleLab))]
	internal abstract class IGUIConsoleLabContract : IGUIConsoleLab
	{
		public Task<bool> ExperimentStartingAsync(IList<IExperiment> experiments, int index)
		{
			Contract.Requires(HasProxy);
			Contract.Requires(experiments != null);
			Contract.Requires(experiments.IsReadOnly);
			Contract.Requires(index >= 0);
			Contract.Requires(index < experiments.Count);
			Contract.Ensures(experiments.Count == Contract.OldValue(experiments.Count));
			Contract.Ensures(Proxy == Contract.OldValue(Proxy));
			Contract.Ensures(HasProxy);
			return null;
		}

		public Task ExperimentExecutingAsync(IList<IExperiment> experiments, int index)
		{
			Contract.Requires(HasProxy);
			Contract.Requires(experiments != null);
			Contract.Requires(experiments.IsReadOnly);
			Contract.Requires(index >= 0);
			Contract.Requires(index < experiments.Count);
			Contract.Ensures(experiments.Count == Contract.OldValue(experiments.Count));
			Contract.Ensures(Proxy == Contract.OldValue(Proxy));
			Contract.Ensures(HasProxy);
			return null;
		}

		public Task ExperimentCompletedAsync(IList<IExperiment> experiments, int index)
		{
			Contract.Requires(HasProxy);
			Contract.Requires(experiments != null);
			Contract.Requires(experiments.IsReadOnly);
			Contract.Requires(index >= 0);
			Contract.Requires(index < experiments.Count);
			Contract.Ensures(experiments.Count == Contract.OldValue(experiments.Count));
			Contract.Ensures(Proxy == Contract.OldValue(Proxy));
			Contract.Ensures(HasProxy);
			return null;
		}

		#region ILab Members
		public bool IsEnabled
		{
			get
			{
				return false;
			}
			set
			{
			}
		}

		public string SourceCode
		{
			get
			{
				return null;
			}
		}

		public string SourceXaml
		{
			get
			{
				return null;
			}
		}

		public Lab Proxy
		{
			get
			{
				return null;
			}
			set
			{
			}
		}

		public bool HasProxy
		{
			get
			{
				return false;
			}
		}

		public bool IsProxy
		{
			get
			{
				return false;
			}
		}

		public ILab ActualLab
		{
			get
			{
				return null;
			}
		}

		public string FormatSourceCode(string source)
		{
			return null;
		}

		public string FormatSourceXaml(string source)
		{
			return null;
		}
		#endregion
	}
}